﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HustQQClient.UI
{
    public partial class TeamChat : Form
    {

        public List<HustQQModel.User> members;
        public HustQQModel.Team team;
        public string teamId;
        public TeamChat(string _teamId)
        {
            InitializeComponent();
            teamId = _teamId;
            //TeamChat_Load(null, null);
        }

        private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e)
        {

        }

        public void ReceiveTeamMsg(string userId, string teamId, string text, DateTime time)
        {
            HustQQModel.User usr = HustQQInterface.InterfaceManager.NetManager.GetUserInformation(userId, false);

            textBox1.Text += usr.name + "(" + userId.Trim() + ")" + time.ToShortTimeString() + "\n"
                + text + "\n";

        }

        private void TeamChat_Load(object sender, EventArgs e)
        {
            members = HustQQInterface.InterfaceManager.NetManager.GetTeamMember(InfoControl.CurrentUser.qq_ID, teamId);
            label1.Text = teamId.Trim();
            listBox1.Items.Add("Team Members :");
            for (int i = 0; i < members.Count(); i++)
            {
                listBox1.Items.Add("");
                listBox1.Items.Add(members[i].name + "(" + members[i].qq_ID.Trim() + ")");
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            string content = textBox2.Text.ToString();
            if (content.Length > 0)
                HustQQInterface.InterfaceManager.NetManager.SendTextToTeam(InfoControl.CurrentUser.qq_ID, teamId, textBox2.Text.ToString());
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void TeamChat_FormClosed(object sender, FormClosedEventArgs e)
        {
            InfoControl.dictTeamChat.Remove(teamId);
        }

    }
}
